package com.alibaba.aone.casestudy.common.utils;

import java.util.Map;

import org.apache.velocity.tools.generic.ValueParser;

import com.alibaba.aone.casestudy.common.entity.AoneUser;

public class UserTool {

    /**
     * The key used for specifying whether or not to prevent templates from reconfiguring this tool. The default is
     * true.
     */
    public static final String LOCK_CONFIG_KEY = "lock-config";
    private boolean            configLocked    = false;

    /**
     * Looks for configuration values in the given params.
     */
    @SuppressWarnings("unchecked")
    public void configure(Map params) {
        if (!configLocked) {
            ValueParser values = new ValueParser(params);
            configure(values);

            // by default, lock down this method after use
            // to prevent templates from re-configuring this instance
            configLocked = values.getBoolean(LOCK_CONFIG_KEY, true);
        }
    }

    /**
     * Does the actual configuration. This is protected, so subclasses may share the same ValueParser and call configure
     * at any time, while preventing templates from doing so when configure(Map) is locked.
     */
    protected void configure(ValueParser values) {
    }

    /**
     * ��õ�ǰ�û�
     * 
     * @return
     */
    public AoneUser getCurrentUser() {
        AoneUser user =  null; //AoneUser.getCurrentUser();
        return user;
    }

    
}
